﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wicresoft.Platform.Workflows.Mobile;
using System.Threading;

namespace WFTest
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class UnitTest1
    {
        public UnitTest1()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestMethod1()
        {
            App.MobileEntitiesConnectionString = "metadata=res://*/Mobile.csdl|res://*/Mobile.ssdl|res://*/Mobile.msl;provider=System.Data.SqlClient;provider connection string=\"Data Source=.;Initial Catalog=Miles;Integrated Security=True;MultipleActiveResultSets=True\"";
            App.SqlPersistStoreConnectionString = "Data Source=.;Initial Catalog=Miles;Integrated Security=True";

            Guid id = ExecuteFlow(
                     new Wicresoft_Platform_Processes_Mobile()
                     {
                         DeployMethod = "预装",
                         LaunchBy = "赵智",
                         LaunchComment = "又一款新手机",
                         LaunchTime = System.DateTime.Now,
                         MobileName = "Nokia 5800",

                         AssignedTo = "陶勇",
                         LastModifiedBy = "赵智",
                         LastModifiedTime = System.DateTime.Now,
                         CurrentState = ProcessState.Launched.ToString(),
                     },
                     ProcessState.UnInitialized);

     
            
        }

        [TestMethod]
        public void TestMethod2()
        {
            App.MobileEntitiesConnectionString = "metadata=res://*/Mobile.csdl|res://*/Mobile.ssdl|res://*/Mobile.msl;provider=System.Data.SqlClient;provider connection string=\"Data Source=.;Initial Catalog=Miles;Integrated Security=True;MultipleActiveResultSets=True\"";
            App.SqlPersistStoreConnectionString = "Data Source=.;Initial Catalog=Miles;Integrated Security=True";

            Guid id = ExecuteFlow(
                     new Wicresoft_Platform_Processes_Mobile()
                     {
                         Id = Guid.Parse("c1969aad-6544-4e66-a90f-b4d5db8cc63f"),

                         PurchaseBy = "陶勇",
                         PurchaseComment = "不就是一部手机嘛",
                         PurchaseTime = System.DateTime.Now,


                         AssignedTo = "陈赟喆",
                         LastModifiedBy = "陶勇",
                         LastModifiedTime = System.DateTime.Now,
                         CurrentState = ProcessState.Purchase.ToString(),
                     },
                     ProcessState.Purchase);



        }


        private Guid ExecuteFlow(Wicresoft_Platform_Processes_Mobile wppMobile, ProcessState state)
        {
            return new Controller().ExecuteFlow(wppMobile, state);
        }

    }
}
